package com.mqtt.IOT;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.paho.client.mqttv3.MqttMessage;

import java.util.Map;


/**
 * @author wang
 * @version 1.0
 * @data 2024/3/25 下午 8:09
 * @desc 描述信息
 */

public class mqttUtil {
    public static Map parseMqttMessageToJson(MqttMessage message) {
        String json = message.toString();
        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> map;
        try {
            map = mapper.readValue(json, Map.class);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return map;
    }
}
